home *** CD-ROM | disk | FTP | other *** search
/ X User Tools / X User Tools (O'Reilly and Associates)(1994).ISO / sources / xrsh / xrsh_57.gz / xrsh_57
Text File  |  1994-06-06  |  45KB  |  1,260 lines

  1.  
  2. #---------------------------------- cut here ----------------------------------
  3. # This is a shell archive.  Remove anything before this line,
  4. # then unpack it by saving it in a file and typing "sh file".
  5. #
  6. # Wrapped by James J Dempsey <jjd@spchp17> on Mon Jun  6 13:14:51 1994
  7. #
  8. # This archive contains:
  9. #    xrsh.sh        xrlogin.sh    xrsh.man    xrlogin.man    
  10. #    COPYRIGHT    ChangeLog    FUTURE-WORK    Imakefile    
  11. #    README        
  12. #
  13. # Existing files will not be overwritten.
  14. # Error checking via wc(1) will be performed.
  15.  
  16. LANG=""; export LANG
  17. PATH=/bin:/usr/bin:$PATH; export PATH
  18.  
  19. if test -f xrsh.sh
  20. then
  21.     echo Ok to overwrite existing file xrsh.sh\?
  22.     read answer
  23.     case "$answer" in
  24.     [yY]*)    echo Proceeding;;
  25.     *)    echo Aborting; exit 1;;
  26.     esac
  27.     rm -f xrsh.sh
  28.     if test -f xrsh.sh
  29.     then
  30.         echo Error: could not remove xrsh.sh, aborting
  31.         exit 1
  32.     fi
  33. fi
  34. echo x - xrsh.sh
  35. cat >xrsh.sh <<'@EOF'
  36. #!/bin/sh
  37.  
  38. # Some System V systems don't understand the #! construct.  
  39. #   If your system does understand it, put ": " at the beginning of the line.
  40. #
  41. XRSH_VER='xrsh version 5.7'
  42. XRSH_RCS='$Header: /nfs/spserv/u5/jjd/xrsh/RCS/xrsh.sh,v 1.9 1994/06/06 17:11:26 jjd Exp $'
  43. XRSH_TIME='Time-stamp: <94/06/06 13:11:12 jjd>'
  44. #
  45. # Copyright 1991 by James J. Dempsey <jjd@bbn.com>
  46. # Permission to use, copy, modify, distribute, and sell this software and its
  47. # documentation for any purpose is hereby granted without fee, provided that
  48. # the above copyright notice appear in all copies and that both that
  49. # copyright notice and this permission notice appear in supporting
  50. # documentation, James J. Dempsey makes no representations about the
  51. # suitability of this software for any purpose.  It is provided "as is"
  52. # without express or implied warranty.
  53. #
  54. #
  55. # xrsh:  start an X11 client on another host
  56. #
  57. # Usage: xrsh [-help] [-version ] [-l username] [-auth authtype] [-screen #] [-pass envlist] \
  58. #    [-debug] [-debug2] hostname [X-command [arguments...]]
  59. #
  60. # Example usage: xrsh expo.lcs.mit.edu xterm
  61. #
  62. # Runs the given command on another host with $DISPLAY set in the environment.
  63. #    Handles authentication using xhost, xauth, or $XAUTHORITY (or none).
  64. #    Xrsh is very careful not to leave any extra processes waiting
  65. #       around on either machine for the client to exit.  In order
  66. #       to achieve this, csh is used on the remote host and all inputs
  67. #       and outputs are redirected to /dev/null.
  68. #    The -debug switch allows you to see errors, but doesn't worry about
  69. #       leaving extra processes around.
  70. #    The -debug2 switch sets -x so that you can see every command
  71. #       executed by the script  (very verbose)
  72. #    The -l switch allows you to use a different login name on the
  73. #       remote host.  -l and its argument are passed directly to rsh.
  74. #    The -help switch prints out the usage message.
  75. #    The -screen switch allows you to start a client on a different screen.
  76. #    If no X command is given, it defaults to xterm.  This means that
  77. #         'xrsh remotehost' will start an xterm on remotehost.
  78. #    If the given command is a path that ends in "xterm", it adds the 
  79. #        arguments "-name xterm-$hostname" where $hostname is the name
  80. #        of the remote host.  This allows you to customize your server's
  81. #        xrdb database to set attributes, such as the window color, based 
  82. #        on the name of remote host.  If you dislike this behaviour, specify
  83. #        your own -name argument to xterm on the xrsh command line.
  84. #
  85. #    Xrsh handles authentication based on the value of $XRSH_AUTH_TYPE or
  86. #        the value of the -auth command line switch.  The value can
  87. #        be xhost, xauth, environment or none.  It defaults to xhost.
  88. #             xhost -- run xhost to enable the remote host to open window
  89. #                      run xhost on the host where the server is running
  90. #             xhost-xterminal -- 
  91. #                      run xhost to enable the remote host to open windows
  92. #                      run xhost on the host where xrsh was first run
  93. #             xauth -- merge the auth entry from this host on the remote
  94. #                        host using xauth via rsh
  95. #             environment -- pass the $XAUTHORITY environment variable from the
  96. #                       local host to the remote host so that a common
  97. #                       NFS accessable authority file can be used everywhere
  98. #             none -- do nothing.  Assume the user has handled authentication.
  99. #
  100. #    If the environment variable XRSH_RSH_ERRORS is set to the name of a file, 
  101. #        any rsh errors will appear in that file on the remote host.
  102. #        If that variable is unset, error messages will be thrown away unless
  103. #        the -debug switch is given. (Note: don't use ~ in the filename
  104. #        because it will expand to ~ on the local host, but try to put the
  105. #        errors in that file on the remote host.)    
  106. #
  107. #
  108. #  COMMON PROBLEMS:
  109. #     * Make sure your PATH environment variable on the remote host is
  110. #           set in your .cshrc or .bashrc so that rsh programs have
  111. #           access to it.  (/bin/sh and /bin/ksh users have a hard time
  112. #           time here since their shells don't execute any init files
  113. #           under rsh.  One way to do this is to use the XRSH_ENVS_TO_PASS
  114. #           environment variable to pass PATH to the remote shell.
  115. #           Optionally, you can type a full path to xrsh.
  116. #           E.g.  xrsh remote-host /usr/bin/X11/xterm
  117. #
  118. #     * Make sure your PATH environment variable on the remote host
  119. #           includes the directory containing the X programs.  This is 
  120. #           often /usr/bin/X11 or /usr/local/bin/X11.
  121. #     * Make sure you have rsh configured to work on the remote host.
  122. #           You can test this by typing:  rsh remote-host echo '$PATH'
  123. #           This will prove that rsh works and show you the PATH that
  124. #           will be used on the remote host.  If you get "Permission 
  125. #           denied." you probably need to update your ~/.rhosts file
  126. #           on the remote host.  See rlogin(1).
  127. #
  128. # Until X11R5, this command used to be called "xon".  The name was
  129. # changed in order to be more descriptive, to have a name that better
  130. # matches its cousin (xrlogin) and to not collide with a similar command
  131. # written by Keith Packard distributed with X11R5.
  132. #
  133. # Written by Jim Dempsey <jjd@bbn.com> with help from Stephen Gildea
  134. #   <gildea@bbn.com> based on an idea by Dave Mankins <dm@think.com>.
  135. # Some additional features due to dgreen@cs.ucla.edu,
  136. #   "David B. Rosen" <rosen@park.bu.edu>, Eero Simoncelli 
  137. #    <eero@whitechapel.media.mit.edu> and  Martin Friedmann 
  138. #    <martin@whitechapel.media.mit.edu>
  139. #   Originally written around 1987.
  140. #   Last modification by jjd@bbn.com.
  141. #   Version 5.1 of xrsh was distributed with X11R5.
  142.  
  143.  
  144. # initialize some variables
  145.  
  146. default_auth_type=xhost   # sites might want to change this
  147. authenv=
  148. foundarg=
  149. progname=`basename $0`
  150. rshoptions=""
  151. passenvs=                # environment variables to pass along
  152. xhostvar=                # used by auth type xhost-xterminal
  153. usage="usage: $progname [-help] [-version] [-l username] [-auth authtype] [-screen #] [-debug] [-debug2] host [cmd [args ...]]"
  154.  
  155. if [ -z "$DISPLAY" ]; then
  156.     echo "$progname: "'$DISPLAY must be set' 1>&2 ;
  157.     exit 1
  158. fi
  159.  
  160. if [ -z "$XRSH_RSH_ERRORS" ]; then
  161.     XRSH_RSH_ERRORS=/dev/null
  162. fi
  163.  
  164. # process command line arguments
  165. until [ "$foundarg" = "no" ]
  166. do
  167.     foundarg=no
  168.     case $1 in
  169.     -version)
  170.         echo "Version: ${XRSH_VER}"
  171.         echo "RCS info: ${XRSH_RCS}"
  172.             echo "Last saved: ${XRSH_TIME}"
  173.             exit 0
  174.         ;;
  175.         -debug)
  176.             debug=t; foundarg=yes; shift;
  177.             ;;
  178.         -debug2)
  179.             set -x; foundarg=yes; shift; 
  180.             ;;
  181.     -help)
  182.             echo $usage; exit 0;
  183.             ;;
  184.         -l)
  185.             shift; rshoptions="-l $1"; foundarg=yes; shift;
  186.             ;;
  187.     -auth)
  188.             shift; XRSH_AUTH_TYPE=$1; foundarg=yes; shift;
  189.             ;;
  190.     -pass)
  191.             shift; XRSH_ENVS_TO_PASS=$1; foundarg=yes; shift;
  192.             ;;
  193.         -screen)
  194.             shift; 
  195.             # this line was blatantly stolen from Keith Packard's xon
  196.             DISPLAY=`echo $DISPLAY|sed 's/:\\([0-9][0-9]*\\)\\.[0-9]/:\1/'`.$1
  197.             foundarg=yes;
  198.             shift;
  199.             ;;
  200.     esac
  201. done
  202.  
  203. if [ "$#" = "0" ]; then
  204.     echo $usage 1>&2; exit 1;
  205. fi
  206.  
  207. clienthost="$1"; shift      # The full remote host name (as full as possible)
  208.  
  209. command=$1
  210. if [ -z "$command" ]; then  # default command to xterm if none specified
  211.     command=xterm
  212. else
  213.     shift
  214. fi
  215.  
  216. # Grab the arguments to the command here so that we don't have to worry
  217. # about restoring them when doing IFS hacking below
  218. xcmdargs="$@"
  219.  
  220. # Try to avoid running hostname.  
  221. # Some shells set $HOST or $HOSTNAME automatically.
  222. localhost=${HOST-${HOSTNAME-`hostname`}}           # The local host name
  223.  
  224. # Remove domain part from hostname.
  225.  
  226. # The following paragraph of IFS based code replaces sed and 
  227. #    runs faster because it doesn't fork.
  228. #       clientshort is remote host name without domain
  229. #clientshort=`echo $clienthost | sed -e 's/\..*$//'` 
  230. oldIFS=$IFS
  231. IFS=.
  232. set  $clienthost
  233. clientshort=$1
  234. IFS=$oldIFS
  235.  
  236. # Find display host
  237.  
  238. # The following paragraph of IFS based code replaces sed and 
  239. #    runs faster because it doesn't fork.
  240. #displayhost=`echo $DISPLAY | sed 's/:.*//'`
  241. oldIFS=$IFS
  242. IFS=:
  243. set  $DISPLAY
  244. case "$#" in
  245.     1) displayhost=$localhost;;
  246.     *) displayhost=$1;;
  247. esac
  248. IFS=$oldIFS
  249.  
  250. case "$displayhost" in
  251.     "unix"|"local"|"")
  252.         displayhost=$localhost;;
  253. esac
  254.  
  255. # People use the -name resource to specify host-specific resources
  256. # such as window color.
  257. if [ `basename "$command"` = "xterm" ]; then
  258.     command="$command -name xterm-$clientshort -title 'xterm@$clientshort'"
  259. fi
  260. if [ $# -ge 1 ]; then
  261.     command="$command $xcmdargs"
  262. fi
  263.  
  264. # Some System V hosts have rsh as "restricted shell" and ucb rsh is remsh
  265. if [ -r /usr/bin/remsh ]; then
  266.     rsh=remsh
  267. elif [ -f /usr/bin/rcmd ]; then       # SCO Unix uses "rcmd" instead of rsh
  268.     rsh=rcmd
  269. else
  270.     rsh=rsh
  271. fi
  272.  
  273. # Construct the new $DISPLAY for the remote client
  274.  
  275. # The following paragraph of IFS based code replaces sed and 
  276. #    runs faster because it doesn't fork.  It also handles the arp stuff.
  277. # newdisplay="`echo $DISPLAY | sed \"s/^[^:]*:/${localhost}:/\"`"
  278. oldIFS=$IFS
  279. IFS=:
  280. set  $DISPLAY
  281. if [ $# = 2 ]; then 
  282.     shift
  283. fi
  284. case "$clienthost" in
  285.     # If the remote host is the localhost, then don't put the hostname
  286.     #  in $DISPLAY and let X find the fastest display path
  287.     "$displayhost")
  288.         newdisplay=:$@
  289.         ;;
  290.     # if a full internet domain name is used, set $DISPLAY
  291.     # using IP address so remote host will be guaranteed return path
  292.     *.*)
  293.         if [ -f /usr/etc/arp ]; then
  294.             arp=/usr/etc/arp
  295.         elif [ -f /etc/arp ] ; then
  296.             arp=/etc/arp
  297.         else
  298.             arp=arp
  299.         fi
  300.         address=`$arp $displayhost |tr ')' '(' | awk  -F'(' '{print $2}'`
  301.         if [ "$address" ]; then
  302.             newdisplay="$address:$@"
  303.         else
  304.             newdisplay="${displayhost}:$@"
  305.         fi
  306.         ;; 
  307.     # A host in the local domain
  308.     *)
  309.         newdisplay="${displayhost}:$@"
  310.         ;;
  311. esac
  312. IFS=$oldIFS
  313.  
  314. # process env variables to pass early so that we can send them 
  315. # in the xauth commands as well as the actual X client rsh command.
  316. # This is necessary for brain-dead shells like ksh which don't run
  317. # any init files to set the path properly.  The user can instead
  318. # send PATH as an XRSH_ENVS_TO_PASS.
  319. for variable in $XRSH_ENVS_TO_PASS
  320. do
  321.     if eval [ \""\${$variable-Xyzzy}"\" != "Xyzzy" ]; then
  322.         eval passenvs="\"setenv $variable '\$$variable'; $passenvs"\"
  323.     fi
  324. done
  325.  
  326.  
  327.  
  328. # Use $XRSH_AUTH_TYPE to determine whether to run xhost, xauth, 
  329. # propagate $XAUTHORITY to the remote host, or do nothing
  330. case ${XRSH_AUTH_TYPE-$default_auth_type} in
  331.   xhost)      
  332.       if [ "$newdisplay" != "$DISPLAY" ]; then
  333.       # If run on the same host as server, allow remote host access X server.
  334.           if [ "$debug" ]; then
  335.               xhost +$clienthost
  336.           else
  337.               xhost +$clienthost > /dev/null 2>&1
  338.           fi
  339.       else
  340.           # If run on a different host as the server, use rsh to allow
  341.           #    access to the host in DISPLAY.
  342.           xhostcmd="setenv DISPLAY $DISPLAY; exec xhost +$clienthost"
  343.  
  344.           if [ "$debug" ]; then
  345.               # send $passenvs in case the user has a brain dead remote shell
  346.               # and needs to be able to pass the PATH env var (e.g. ksh)
  347.               echo "Executing \"xhost +$clienthost\" on $displayhost with DISPLAY=$DISPLAY"
  348.               $rsh "$displayhost"  exec /bin/csh -cf "\"$passenvs $xhostcmd\"" < /dev/null
  349.           else
  350.               $rsh "$displayhost"  exec /bin/csh -cf "\"$passenvs $xhostcmd < /dev/null >& /dev/null\"" < /dev/null > /dev/null 2>&1
  351.           fi
  352.       fi
  353.       ;;
  354.   xhost-xterminal)
  355.       # If run on an X terminal, rsh to the XDMCP host to run xhost
  356.       # if this is the first time, we are on the XDMCP host and 
  357.       # we can just run xhost.
  358.       if [ "$XHOST" = "" ]; then
  359.           xhostvar="setenv XHOST $localhost; "
  360.           if [ "$debug" ]; then
  361.               xhost +$clienthost
  362.           else
  363.               xhost +$clienthost > /dev/null 2>&1 
  364.           fi
  365.       else
  366.           xhostvar="setenv XHOST $XHOST; "
  367.           xhostcmd="setenv DISPLAY $DISPLAY; exec xhost +$clienthost"
  368.       # send $passenvs in case the user has a brain dead remote shell
  369.           # and needs to be able to pass the PATH env var (e.g. ksh)
  370.           if [ "$debug" ]; then
  371.               echo "Executing \"xhost +$clienthost\" on $XHOST with DISPLAY=$DISPLAY"
  372.               $rsh "$XHOST"  exec /bin/csh -cf "\"$passenvs $xhostcmd\"" < /dev/null
  373.           else
  374.               $rsh "$XHOST"  exec /bin/csh -cf "\"$passenvs $xhostcmd < /dev/null >& /dev/null\"" > /dev/null < /dev/null 2>&1
  375.           fi
  376.       fi
  377.       ;;
  378.   xauth)
  379.       # the "xauth remove" is theoretically unnecessary below,
  380.       # but due to a bug in the initial X11R5 (fixed in fix-09) xauth,
  381.       # entries for MIT-MAGIC-COOKIE-1 get lost if
  382.       # you do merge twice without the remove.  The remove
  383.       # command can be removed when xauth gets fixed.
  384.       if [ "$debug" ]; then
  385.           xauth extract - $newdisplay | \
  386.           $rsh $clienthost $rshoptions exec /bin/csh -cf "\"$passenvs xauth remove $newdisplay ; xauth merge -\""
  387.       else
  388.           # Conditionalize this on $passenvs so that we don't pay the price
  389.           # of forking a csh on the remote host if we don't need environment
  390.           # variables evaluated.
  391.           if [ "$passenvs" ]; then
  392.               xauth extract - $newdisplay | \
  393.               $rsh $clienthost $rshoptions exec /bin/csh -cf "\"$passenvs xauth remove $newdisplay ; xauth merge -\"" >/dev/null 2>&1 < /dev/null
  394.           else
  395.               xauth extract - $newdisplay | \
  396.               $rsh $clienthost $rshoptions xauth remove $newdisplay \;xauth merge - >/dev/null 2>&1 < /dev/null
  397.           fi
  398.       fi
  399.       ;;
  400.   none)
  401.       ;;
  402.   environment)
  403.       authenv="setenv XAUTHORITY $XAUTHORITY; "
  404.       ;;
  405.   *)
  406.       echo -n "$progname: "'$XRSH_AUTH_TYPE must be set to "xhost", ' 1>&2
  407.       echo '"xhost-xterminal", "xauth", "environment" or left unset' 1>&2
  408.       exit 1
  409.       ;;
  410. esac
  411.  
  412.  
  413. # Do the real work using rsh.
  414. # Don't use -n to rsh because SG IRIX doesn't support it.  
  415. # Use < /dev/null instead.
  416. if [ "$debug" ]; then
  417.     echo "Executing \"$command\" on $clienthost with DISPLAY=$newdisplay"
  418.     $rsh $clienthost $rshoptions /bin/csh -cf "\"setenv DISPLAY $newdisplay; $authenv $xhostvar $passenvs $command\"" < /dev/null
  419. else
  420. #
  421. # The redirection inside the innermost quotes is done by csh.  The outer
  422. # redirection is done by whatever shell the user uses on the remote end.
  423. # The inner redirection is necessary for an error log -- the outer 
  424. # redirection is necessary to make sure that the local rsh doesn't hang around.
  425. #
  426. # The outermost < /dev/null is to simulate the -n argument to rsh which 
  427. # we don't want to use for portability reasons.
  428. #
  429. # The three sets of redirections are for the local shell, the login shell
  430. # on the remote host and the csh on the remote host.
  431. #
  432. # We would like the last '>' to be '>&' or equivalent, but that would make this
  433. # code dependent on what flavor of shell the user uses on the remote host
  434. #
  435.     exec $rsh  $clienthost $rshoptions exec /bin/csh -cf "\"setenv DISPLAY $newdisplay; $authenv $xhostvar $passenvs exec $command < /dev/null >>& $XRSH_RSH_ERRORS \" < /dev/null > /dev/null " < /dev/null 
  436.  
  437. fi
  438.  
  439.  
  440.  
  441. @EOF
  442. set `wc -lwc <xrsh.sh`
  443. if test $1$2$3 != 406229915679
  444. then
  445.     echo ERROR: wc results of xrsh.sh are $* should be 406 2299 15679
  446. fi
  447.  
  448. chmod 555 xrsh.sh
  449.  
  450. if test -f xrlogin.sh
  451. then
  452.     echo Ok to overwrite existing file xrlogin.sh\?
  453.     read answer
  454.     case "$answer" in
  455.     [yY]*)    echo Proceeding;;
  456.     *)    echo Aborting; exit 1;;
  457.     esac
  458.     rm -f xrlogin.sh
  459.     if test -f xrlogin.sh
  460.     then
  461.         echo Error: could not remove xrlogin.sh, aborting
  462.         exit 1
  463.     fi
  464. fi
  465. echo x - xrlogin.sh
  466. cat >xrlogin.sh <<'@EOF'
  467. #!/bin/sh
  468. # Some System V systems don't understand the #! construct.  
  469. #       In this case replace the first line with just a colon (:)
  470. #
  471. # Copyright 1991 by James J. Dempsey <jjd@bbn.com>
  472. #  Version 5.3
  473. #  Time-stamp: <92/09/14 09:58:49 jjd>
  474. # Permission to use, copy, modify, distribute, and sell this software and its
  475. # documentation for any purpose is hereby granted without fee, provided that
  476. # the above copyright notice appear in all copies and that both that
  477. # copyright notice and this permission notice appear in supporting
  478. # documentation, James J. Dempsey makes no representations about the
  479. # suitability of this software for any purpose.  It is provided "as is"
  480. # without express or implied warranty.
  481. #
  482. # Starts a local xterm running rlogin or telnet
  483. # Written by Stephen Gildea <gildea@expo.lcs.mit.edu> 
  484. #     and Jim Dempsey <jjd@bbn.com>
  485. #
  486. # Usage: xrlogin [-l username] [-telnet] [emulator options] hostname
  487.  
  488. # Set some defaults.
  489. progname=`basename $0`
  490. usage="usage: $progname [-l logname] [-telnet] [emulator options] host"
  491. netprog="rlogin"
  492. netprogopts="-8"
  493. termprog=xterm
  494. termprogopts=
  495. telnet=
  496. user=
  497. host=
  498.  
  499. # process arguments
  500. while [ "$*" != "" ]; do
  501.     case "$1" in 
  502.       -telnet)
  503.           telnet=t;
  504.           ;;
  505.       -l)
  506.           if [ "$telnet" ]; then
  507.               echo "$progname: Can't use -l with -telnet" 1>&2
  508.               echo $usage 1>&2
  509.               exit 1
  510.           fi
  511.           user=$2; shift;
  512.           ;;
  513.       *)
  514.       # assume anything else is an argument to terminal emulator
  515.           #  (except the last one which is the hostname)
  516.       termprogopts="$termprogopts $1"
  517.           ;;
  518.     esac
  519.     shift
  520. done
  521.  
  522. if [ "$user" -a "$telnet" ]; then
  523.     echo "$progname: Can't use -l with -telnet" 1>&2
  524.     echo $usage 1>&2
  525.     exit 1
  526. fi
  527.  
  528. if [ "$telnet" ]; then
  529.     netprog=telnet;
  530.     netprogopts= ;
  531. fi
  532. if [ "$user" ]; then
  533.     netprogopts="$netprogopts -l $user"
  534. fi
  535.  
  536. # last item in termprogopts is the hostname by definition 
  537. #    (arg list and man page)
  538. item=
  539. # xyzzy keeps shell from getting confused if option begins with '-'
  540. set xyzzy $termprogopts
  541. termprogopts=
  542. shift
  543. for i in $@
  544. do
  545.     if [ ! -z "${item}" ]; then
  546.         termprogopts="$termprogopts $item"
  547.     fi
  548.     item=$i
  549. done
  550. host=$item
  551.  
  552. if [ "$XRLOGIN_TERM_EMULATOR" != "" ]; then
  553.     termprog=$XRLOGIN_TERM_EMULATOR
  554. else
  555.     case "$TERM" in
  556.       *term)
  557.     # TERM looks like it is an X11 terminal emulator, so use it.
  558.     # Should also look for *terminalEmulatorName resource.
  559.         termprog=$TERM;;
  560.     esac
  561. fi
  562.  
  563. if [ "$termprog" = "xterm" ]; then
  564.     termprogopts="$termprogopts -ut"
  565. fi
  566.  
  567. # Remove domain part from hostname.
  568. name=`echo $host | sed -e 's/\..*$//'`
  569.  
  570. # netprogopts are required to go after hostname on some SYS V hosts
  571. exec $termprog -name $termprog-$name -title $name $termprogopts -e $netprog $host $netprogopts
  572. @EOF
  573. set `wc -lwc <xrlogin.sh`
  574. if test $1$2$3 != 1064092827
  575. then
  576.     echo ERROR: wc results of xrlogin.sh are $* should be 106 409 2827
  577. fi
  578.  
  579. chmod 555 xrlogin.sh
  580.  
  581. if test -f xrsh.man
  582. then
  583.     echo Ok to overwrite existing file xrsh.man\?
  584.     read answer
  585.     case "$answer" in
  586.     [yY]*)    echo Proceeding;;
  587.     *)    echo Aborting; exit 1;;
  588.     esac
  589.     rm -f xrsh.man
  590.     if test -f xrsh.man
  591.     then
  592.         echo Error: could not remove xrsh.man, aborting
  593.         exit 1
  594.     fi
  595. fi
  596. echo x - xrsh.man
  597. cat >xrsh.man <<'@EOF'
  598. .\" Copyright 1991,1994 by James J. Dempsey <jjd@bbn.com>
  599. .\" 
  600. .\" Permission to use, copy, modify, distribute, and sell this software and its
  601. .\" documentation for any purpose is hereby granted without fee, provided that
  602. .\" the above copyright notice appear in all copies and that both that
  603. .\" copyright notice and this permission notice appear in supporting
  604. .\" documentation, James J. Dempsey makes no representations about the
  605. .\" suitability of this software for any purpose.  It is provided "as is"
  606. .\" without express or implied warranty.
  607. .TH XRSH 1 "Release 6" "X Version 11"
  608. .SH NAME
  609. xrsh \- start an X program on a remote machine
  610. .SH SYNOPSIS
  611. .B xrsh
  612. [
  613. .B \-help
  614. ] [
  615. .B \-version
  616. ] [
  617. .B \-l
  618. .I username
  619. ] [
  620. .B \-auth
  621. .I authtype
  622. ] [
  623. .B \-screen
  624. .I screen-#
  625. ] [
  626. .B \-pass
  627. .I envlist
  628. ] [
  629. .B \-debug
  630. ] [
  631. .B \-debug2
  632. ]
  633. .I remote-host
  634. [
  635. .I X-command
  636. [
  637. .I arguments ... ] ]
  638. .SH DESCRIPTION
  639. .I Xrsh
  640. runs the given X command on a remote host.  It sets up the environment for 
  641. that command such that it will display its windows on the current
  642. server's screen by propagating the $DISPLAY environment variable. 
  643. If not specified, the default client is \fIxterm\fP.  Xrsh automatically
  644. selects \fIrsh\fP(1), \fIremsh\fP(1) or \fIrcmd\fP(1) to execute remote commands, depending 
  645. on what is available the O/S environment. 
  646. .PP
  647. Xrsh automatically handles authentication so that the remote client
  648. will be allowed to open windows on the server.  It does this in
  649. several different ways depending on the value of the $XRSH_AUTH_TYPE
  650. environment variable or the \-auth argument.
  651. .PP
  652. By default, xrsh will use xhost to enable the remote client to open a
  653. server connection.  It can also be told to use xauth to merge local
  654. keys into a remote authorization file.   Or it can pass the $XAUTHORITY
  655. environment variable to the remote host in order to share a common NFS
  656. mounted authority file.  It can also be directed to do nothing in the
  657. case where no explicit authorization is necessary.
  658. .PP
  659. Users who just want a remote terminal window might look at xrsh's
  660. sister command, xrlogin(1).  Xrlogin uses a locally running xterm to
  661. open an rlogin connection to a remote host.  The decision on whether
  662. to use "xrsh host xterm" or "xrlogin host" should be based on several
  663. factors.  If X is unavailable on the remote host or the local terminal 
  664. emulator has better features, use xrlogin.  In general, the author 
  665. recommends using xrsh over xrlogin in most situations.
  666. .PP
  667. If the command to execute on the remote host is an xterm, xrsh
  668. automatically passes the -name argument to xterm with a value of
  669. "xterm-hostname" where hostname is the name of the remote host.  This
  670. allows the user to specify resources in their server's resource
  671. manager which are specific to xterms from a given host.  For example,
  672. this feature can be used to make all xterm windows from a given remote
  673. host be the same color or use a specific font or start up in a
  674. specific place on the screen.  Xrlogin passes the same string so they
  675. are compatible in this regard.  This feature can be overridden by
  676. specifying your own -name argument on the xterm command line.
  677. .PP
  678. If the command to execute on the remote host is an xterm, xrsh specifies 
  679. that the default title for the new xterm will be "xterm@hostname"
  680. where hostname is the name of the remote host.  This can also be
  681. overridden by specifying your own -title argument on the xterm command
  682. line.
  683. .PP
  684. Xrsh is very careful not to leave any extra processes 
  685. on either the local or remote machine waiting around for the client to
  686. exit.  In some remote environments (particularly some Sys V
  687. implementations of csh and rsh), this is impossible and xrsh should be
  688. run as a background command.
  689. .SH OPTIONS
  690. Note that xrsh options precede the given X command and its arguments.
  691. .sp
  692. .IP "\fB\-auth authtype\fP"
  693. Choose what type of X authorization (or access control) is going to be
  694. used.  Authtype can be one of "xhost", "xauth", "xhost-xterminal", "environment", or
  695. "none".  The default is xhost, but the default can be set by setting
  696. the value of the environment variable $XRSH_AUTH_TYPE.
  697. .IP
  698. If xhost is specified and the X server is running on the local
  699. machine, xhost will be run locally to enable the remote host to open an X
  700. connection.  If the server is on a third host (not the one where xrsh
  701. is running and not the one where you wish to run the command), rsh will
  702. be used to run xhost on the server host to authorize the host where
  703. the command will be run.
  704. .IP
  705. If xauth is specified, then xrsh will merge the entries for the server from 
  706. the local $XAUTHORITY file into that of the remote host using rsh.
  707. .IP
  708. The authtype xhost-xterminal is intended for use by people using X terminals.
  709. If xhost-xterminal is used, then the first time xrsh is run, it runs xhost locally to 
  710. enable the remote host for access.  This should work since (theoretically)
  711. the first time it is run is on the XDMCP host for the X terminal.  From then
  712. on it propagates the name of that host to all remote hosts via the environment
  713. variable $XHOST.  In subsequent invocations from remote hosts, xrsh uses rsh
  714. to connect to the host $XHOST and run xhost to enable new remote hosts.
  715. .IP 
  716. Authtype "none" does no explicit work for access control.  Use this if you 
  717. don't enable access control or if you use another mechanism for access
  718. control.
  719. .IP
  720. Finally, authtype "environment" automatically propagates the environment
  721. variable $XAUTHORITY to remote hosts, assuming that it is an NFS 
  722. mounted location that can be accessed from all hosts.
  723. .IP "\fB-debug\fP"
  724. Normally xrsh redirects standard input and standard output to
  725. /dev/null in an effort to cause unneeded rshd and shell processes to
  726. exit.  As a result, the user can't usually see any errors that might
  727. occur (like a "Permission denied." from rsh).  If you are having
  728. trouble getting xrsh to work with a remote host, try giving the -debug
  729. switch to see if any errors are being generated.
  730. .IP "\fB-debug2\fP"
  731. This switch causes xrsh to turn on the -x option in the shell so that
  732. the user can see every shell command executed by xrsh.  Only use this
  733. script if you are debugging the xrsh code itself.
  734. .IP "\fB-help\fP"
  735. Print out the argument list to standard output.
  736. .IP "\fB-l username\fP"
  737. Use the -l switch to specify a different user name to use for logging
  738. in via rsh on the remote host.
  739. .IP "\fB-pass envlist\fP"
  740. Envlist is a quote delimited string naming an arbitrary set of
  741. environment variables to pass on to the shell environment on the
  742. remote host.  If one wanted to set $XRSH_AUTH_TYPE and $XAUTHORITY to
  743. the remote host, one could use: -pass "XRSH_AUTH_TYPE XAUTHORITY".  
  744. A default set of environment variables to pass may be set using the
  745. environment variable $XRSH_ENVS_TO_PASS.
  746. .IP "\fB-screen screen-#\fP"
  747. Specify a different screen on the server on which to display the
  748. remote client.
  749. .IP "\fB-version\fP"
  750. Print out version information and exit.
  751. .SH ENVIRONMENT
  752. The environment variables XRSH_AUTH_TYPE and XRSH_ENVS_TO_PASS which
  753. can be used to set switch defaults are overridden if the equivalent
  754. switch is specified as well.
  755. .IP "\fBXAUTHORITY\fP"
  756. The $XAUTHORITY environment variable is passed to the remote host if
  757. the authtype specified by -auth or $XRSH_AUTH_TYPE is "environment".
  758. .IP "\fBXRSH_AUTH_TYPE\fP"
  759. This environment variable can be used to specify the default type of
  760. authorization or access control.  The values it can be set to are the
  761. same as the values for the argument -auth.
  762. .IP "\fBXRSH_RSH_ERRORS\fP"
  763. If the environment variable XRSH_RSH_ERRORS is set to the name of a file, 
  764. any rsh errors will appear in that file on the remote host.
  765. If that variable is unset, error messages will be thrown away unless
  766. the -debug switch is given. (Note: don't use ~ in the filename
  767. because it will expand to ~ on the local host, but try to put the
  768. errors in that file on the remote host.)    
  769. .IP "\fBXRSH_ENVS_TO_PASS\fP"
  770. .SH COMMON PROBLEMS
  771. Make sure your PATH environment variable on the remote host is
  772. set in your .cshrc or .bashrc so that rsh programs have
  773. access to it.  (/bin/sh and /bin/ksh users have a hard time
  774. time here since their shells don't execute any init files
  775. under rsh.  You can use the XRSH_ENVS_TO_PASS environment variable
  776. to pass the PATH environment variable to the remote host.  Optionally,
  777. you can type  a full path to xrsh in that case.
  778. (E.g.  xrsh remote-host /usr/bin/X11/xterm))
  779. .PP
  780. Make sure your PATH environment variable on the remote host
  781. includes the directory containing the X programs.  This is 
  782. often /usr/bin/X11 or /usr/local/bin/X11.
  783. .PP
  784. Make sure you have rsh configured to work on the remote host.
  785. You can test this by typing:  rsh remote-host echo '$PATH'
  786. This will prove that rsh works and show you the PATH that
  787. will be used on the remote host.  If you get "Permission 
  788. denied." you probably need to update your ~/.rhosts file
  789. on the remote host.  See rlogin(1).
  790. .SH EXAMPLES
  791. .IP "xrsh yoda"
  792. Start an xterm on the host yoda which displays on the current X
  793. server.  Use xhost for access control.
  794. .IP "xrsh -auth xauth underdog emacs"
  795. Start an emacs on the host underdog.  Merge xauth authorization
  796. entries for this server into the authority file on the remote host.
  797. .IP "xrsh -l mjd -auth none -pass XRSH_AUTH_TYPE -debug tigger xterm -fn 5x7"
  798. Start an xterm on the host tigger in a very small font, propagate the
  799. environment variable $XRSH_AUTH_TYPE to the remote host, login to the
  800. remote host using the id "mjd", don't do any specific authorization
  801. and don't redirect standard/error output to /dev/null so I can see any errors.
  802. .SH BUGS
  803. .PP
  804. If the values of the environment variables specified in -pass or
  805. $XRSH_ENVS_TO_PASS contain quote characters, xrsh will have difficulty.
  806. .PP
  807. If the remote host can't resolve the hostname of the server host
  808. (through /etc/hosts, DNS or NIS), the remote client will not be able
  809. to open a connection to the server.
  810. .PP
  811. System V users may need to make the first line of the script begin
  812. with colon (:).
  813. .SH SEE ALSO
  814. .PP
  815. xrlogin(1), rsh(1), xhost(1), xauth(1)
  816. .SH AUTHOR
  817. James J. Dempsey <jjd@bbn.com> with help and suggestions from many
  818. people including gildea@expo.lcs.mit.edu, dm@think.com,
  819. dgreen@cs.ucla.edu and rosen@cns.bu.edu,  <eero@whitechapel.media.mit.edu>, 
  820. and  <martin@whitechapel.media.mit.edu>.
  821. @EOF
  822. set `wc -lwc <xrsh.man`
  823. if test $1$2$3 != 223172510259
  824. then
  825.     echo ERROR: wc results of xrsh.man are $* should be 223 1725 10259
  826. fi
  827.  
  828. chmod 444 xrsh.man
  829.  
  830. if test -f xrlogin.man
  831. then
  832.     echo Ok to overwrite existing file xrlogin.man\?
  833.     read answer
  834.     case "$answer" in
  835.     [yY]*)    echo Proceeding;;
  836.     *)    echo Aborting; exit 1;;
  837.     esac
  838.     rm -f xrlogin.man
  839.     if test -f xrlogin.man
  840.     then
  841.         echo Error: could not remove xrlogin.man, aborting
  842.         exit 1
  843.     fi
  844. fi
  845. echo x - xrlogin.man
  846. cat >xrlogin.man <<'@EOF'
  847. .\" Copyright 1991,1994 by James J. Dempsey <jjd@bbn.com>
  848. .\" 
  849. .\" Permission to use, copy, modify, distribute, and sell this software and its
  850. .\" documentation for any purpose is hereby granted without fee, provided that
  851. .\" the above copyright notice appear in all copies and that both that
  852. .\" copyright notice and this permission notice appear in supporting
  853. .\" documentation, James J. Dempsey makes no representations about the
  854. .\" suitability of this software for any purpose.  It is provided "as is"
  855. .\" without express or implied warranty.
  856. .TH XRLOGIN 1 "Release 6" "X Version 11"
  857. .SH NAME
  858. xrlogin \- start an xterm that uses rlogin or telnet to connect to a remote host
  859. .SH SYNOPSIS
  860. .B xrlogin
  861. [-l username] [-telnet] [xterm options] remote-host
  862. .SH DESCRIPTION
  863. .I Xrlogin
  864. opens an xterm window and runs rlogin or telnet to login to a remote host.
  865. .PP
  866. Xrlogin
  867. automatically passes the -name argument to xterm with a value of
  868. "xterm-hostname" where hostname is the name of the remote host.  This
  869. allows the user to specify resources in their server's resource
  870. manager which are specific to xterms from a given host.  For example,
  871. this feature can be used to make all xterm windows to a given remote
  872. host be the same color or use a specific font or start up in a
  873. specific place on the screen.  Xrsh(1) passes the same string so they
  874. are compatible in this regard.  
  875. .PP
  876. Xrlogin specifies that the default title for the new xterm will be
  877. "hostname" where hostname is the name of the remote host.  This and
  878. the -name argument above can be overridden with xterm-options on the
  879. command line.
  880. .PP
  881. One could also use xrlogin's sister command xrsh(1) to open a window
  882. to a remote host.  In the case of xrsh, the xterm would run on the
  883. remote host and use X as the connection protocol while xrlogin would
  884. run the xterm on the local host and use rlogin or telnet as the
  885. connection protocol.  See xrsh(1) for a discussion of the merits of
  886. each scheme.
  887. .SH OPTIONS
  888. .IP "\fB-l username\fP"
  889. When not using -telnet, use username as the id to login to the remote
  890. host.
  891. .IP "\fB-telnet\fP"
  892. Use the -telnet protocol to open the connection instead of rlogin.  In
  893. general rlogin is preferred because it can be configured to not prompt
  894. the user for a password.  Rlogin also automatically propagates window
  895. size change signals (SIGWINCH) to the remote host so that applications
  896. running there will learn of a new window size.  Use of telnet
  897. provided mostly for hosts that don't support rlogin.
  898. .SH COMMON PROBLEMS
  899. Make sure that the local host is specified in the .rhosts file on the
  900. remote host or in the remote hosts /etc/hosts.equiv file.  See
  901. rlogin(1) for more information.
  902. .SH EXAMPLES
  903. .IP "xrlogin -bg red yoda"
  904. Start a local red xterm which connects to the remote host yoda using rlogin.
  905. .IP "xrlogin -telnet c70"
  906. Open a local xterm which connects to the remote host c70 using telnet.
  907. .SH SEE ALSO
  908. .PP
  909. xrsh(1), rlogin(1), telnet(1)
  910. .SH AUTHOR
  911. James J. Dempsey <jjd@bbn.com> and Stephen Gildea <gildea@expo.lcs.mit.edu>.
  912. @EOF
  913. set `wc -lwc <xrlogin.man`
  914. if test $1$2$3 != 655113013
  915. then
  916.     echo ERROR: wc results of xrlogin.man are $* should be 65 511 3013
  917. fi
  918.  
  919. chmod 444 xrlogin.man
  920.  
  921. if test -f COPYRIGHT
  922. then
  923.     echo Ok to overwrite existing file COPYRIGHT\?
  924.     read answer
  925.     case "$answer" in
  926.     [yY]*)    echo Proceeding;;
  927.     *)    echo Aborting; exit 1;;
  928.     esac
  929.     rm -f COPYRIGHT
  930.     if test -f COPYRIGHT
  931.     then
  932.         echo Error: could not remove COPYRIGHT, aborting
  933.         exit 1
  934.     fi
  935. fi
  936. echo x - COPYRIGHT
  937. cat >COPYRIGHT <<'@EOF'
  938. # Copyright 1991,1994 by James J. Dempsey <jjd@bbn.com>
  939. # Permission to use, copy, modify, distribute, and sell this software and its
  940. # documentation for any purpose is hereby granted without fee, provided that
  941. # the above copyright notice appear in all copies and that both that
  942. # copyright notice and this permission notice appear in supporting
  943. # documentation, James J. Dempsey makes no representations about the
  944. # suitability of this software for any purpose.  It is provided "as is"
  945. # without express or implied warranty.
  946. @EOF
  947. set `wc -lwc <COPYRIGHT`
  948. if test $1$2$3 != 986530
  949. then
  950.     echo ERROR: wc results of COPYRIGHT are $* should be 9 86 530
  951. fi
  952.  
  953. chmod 444 COPYRIGHT
  954.  
  955. if test -f ChangeLog
  956. then
  957.     echo Ok to overwrite existing file ChangeLog\?
  958.     read answer
  959.     case "$answer" in
  960.     [yY]*)    echo Proceeding;;
  961.     *)    echo Aborting; exit 1;;
  962.     esac
  963.     rm -f ChangeLog
  964.     if test -f ChangeLog
  965.     then
  966.         echo Error: could not remove ChangeLog, aborting
  967.         exit 1
  968.     fi
  969. fi
  970. echo x - ChangeLog
  971. cat >ChangeLog <<'@EOF'
  972. Mon Jun  6 11:10:23 1994  James J Dempsey  (jjd@spchp17.BBN.COM)
  973.  
  974.     * Added some /dev/null redirections to rsh commands to fix hanging
  975.     problem when using csh as login shell and xrsh'ing to some remote
  976.     OSes like HP-UX.  Upped version to 5.7.
  977.  
  978.     * Changed Imakefile comments from # to XCOMM as per gildea@x.org. 
  979.     * Added double quotes around assignment of xcmdargs at gildea's
  980.     suggestion.
  981.  
  982. Fri Jun  3 11:10:23 1994  James J Dempsey  (jjd@spchp17.BBN.COM)
  983.  
  984.     * Released version 5.6 to X Consortium for X11R6 contrib after
  985.     making only minor cosmetic changes from the version called 5.6
  986.     below.  Most (all?) of the changes were in the supporting README
  987.     type files and man pages.
  988.  
  989. Fri Mar 18 17:22:46 1994  James J Dempsey  (jjd@spchp17)
  990.  
  991.     * Added -version feature at the request of rws@x.org
  992.     Now at version 5.6.
  993.  
  994. Mon Sep 14 09:57:27 1992  James J Dempsey  (jjd at spchp17)
  995.  
  996.     * Fixed a bug in xrlogin reported by dave@csis.dit.csiro.au.
  997.     The problem was that if xterm options were sent in on the xrlogin
  998.     cmd line, $item wasn't set and generates a "test: arg expected"
  999.     error.  Replaced with [ ! -z ""].  Updated version to 5.3.
  1000.  
  1001. Fri Jun  5 10:06:39 1992  James J Dempsey  (jjd@spchp17)
  1002.  
  1003.     * Fixed line in xrsh.man which caused groff to barf due to 
  1004.     quoting.  Reported by Paul Eggert <eggert@twinsun.com>     
  1005.  
  1006. Thu Apr 16 15:32:39 1992  James J Dempsey  (jjd@spchp17)
  1007.  
  1008.     * Changed the xrsh man page to remove the restriction that ultrix
  1009.     should run with /bin/sh5.  Now that I use "set -" instead of "set
  1010.     --" it works with the old Ultrix /bin/sh again.
  1011.  
  1012. Mon Mar  9 15:28:09 1992  James J Dempsey  (jjd@spchp17)
  1013.  
  1014.     * made some changes to xrsh and xrlogin due to suggestions
  1015.     by Charles Karney <karney@theory.pppl.gov>. 
  1016.  
  1017.     Changed xrlogin to take arbitrary xterm options.  Made those
  1018.     options be after "-name -title" so users can override.
  1019.  
  1020.     Fixed a bug where client host was checking to see if it was the
  1021.     same as localhost in order to set display to :0, when it should
  1022.     have been checking to see if it was the same as displayhost.
  1023.  
  1024.     Added default_auth_type so sites can customize the default
  1025.     authorization to be something other than xhost.
  1026.  
  1027.     New xrsh version 5.3.
  1028.     New xrlogin version 5.2.
  1029.  
  1030. @EOF
  1031. set `wc -lwc <ChangeLog`
  1032. if test $1$2$3 != 583582185
  1033. then
  1034.     echo ERROR: wc results of ChangeLog are $* should be 58 358 2185
  1035. fi
  1036.  
  1037. chmod 444 ChangeLog
  1038.  
  1039. if test -f FUTURE-WORK
  1040. then
  1041.     echo Ok to overwrite existing file FUTURE-WORK\?
  1042.     read answer
  1043.     case "$answer" in
  1044.     [yY]*)    echo Proceeding;;
  1045.     *)    echo Aborting; exit 1;;
  1046.     esac
  1047.     rm -f FUTURE-WORK
  1048.     if test -f FUTURE-WORK
  1049.     then
  1050.         echo Error: could not remove FUTURE-WORK, aborting
  1051.         exit 1
  1052.     fi
  1053. fi
  1054. echo x - FUTURE-WORK
  1055. cat >FUTURE-WORK <<'@EOF'
  1056. Here are some unstated goals for the xrsh script to consider in
  1057. designing enhancements:
  1058.  
  1059. 1. Keep xrsh as one script.  Configuration and installation are more
  1060. difficult with ancillary files.  As one script, it can be copied
  1061. easily from system to system.
  1062.  
  1063. 2. Keep xrsh portable.  Avoid features which might not work on all
  1064. UNIX variants.  E.g. some rsh don't have a -n option.  Some
  1065. /bin/sh don't have shell functions.
  1066.  
  1067. 3. Keep the number of programs fork()ed by xrsh to a minimum.  xrsh is
  1068. used a lot and always interactively so speed is important.  This is
  1069. why I play all those games with IFS, to avoid forking awk or sed.
  1070.  
  1071. Here are some things which might be done in the future or have been
  1072. recently tried. 
  1073.  
  1074. 1. Parse the DISPLAY environment variable without forking any extra
  1075. processes like sed.  Perhaps use IFS in the shell.
  1076. <done, but doesn't work in Ultrix /bin/sh>
  1077.  
  1078. 2. Pass other environment variables besides $DISPLAY.  Users might
  1079. want to pass an arbitrary set.
  1080. <can now pass XAUTHORITY using XRSH_AUTH_TYPE and arbitrary
  1081.   environment variables using XRSH_ENVS_TO_PASS>
  1082.  
  1083. 3. Don't use backslashes for quoting, only  use only ' and " for portability.
  1084. <What hosts don't handle backslashes?  This turns out to be very hard.>
  1085.  
  1086. 4. Pass  $XUSERFILESEARCHPATH to the remote host?
  1087. <I'm not sure this is always what you want to do, but you can
  1088.   do it if you want to using XRSH_ENVS_TO_PASS.>
  1089.  
  1090. 5. Add command line flag to describe the remote machine (like -sysv or
  1091. -irix).  This would get all the config options correct without having
  1092. to guess.
  1093. <I hope not to have to do this -- I hope to make the one script portable.>
  1094.  
  1095. 6. If you have to rsh the xhost to the serverhost, run it in the
  1096.      background and use wait before the final rsh to improve speed.
  1097. <I did this, but it made some system V hosts (HP-UX 7.0) go insane and
  1098. say "wait: pid 232 is not a child of this shell" over and over again.
  1099. I finally deleted it in the interests of portability.  Timing showed
  1100. it wasn't a major win in speed anyway>
  1101.  
  1102. 7. Expand DISPLAY environment variable  from foo to foo.org.com so
  1103. that it works when you leave your local site.
  1104. <hard to do in a site independent manner.  Now uses ip addresses if the 
  1105. remote host name contains periods like foo.bar.com>
  1106.  
  1107. 8. Decide rsh vs. remsh vs. rcmd at install time instead of run time.
  1108. <disadvantage:  one script can't be transferred from one machine to another>
  1109.  
  1110. 9. make first line be : instead of #!
  1111. <Can't -- without #! some systems use $SHELL to eval scripts.  May not
  1112. be the right thing>
  1113.  
  1114. 10. Use IP address when setting $DISPLAY for remote hosts that can't
  1115. resolve local hostname.
  1116. <This is done for remote host names with . in them>
  1117.  
  1118. 11. Have an .xrsh.rc file which can be used to tailor defaults for
  1119. specific hosts.
  1120.  
  1121. 12. If using xhsot authorization, optionally disable access to the
  1122. host after running the command.  Of course, on hosts where rshd
  1123. doesn't return, the xhost -host would never get executed until the
  1124. client exitied.  This feature was requested by Rick Calder, NCR
  1125. Systems Support Center - New Jersey [att!]rick!rick rick@rick.att.com
  1126. attmail!rcalder.
  1127.  
  1128.  
  1129. 13. (From kmp@harlequin via gildea@expo.lcs.mit.edu) in order to preserver
  1130. users quoting for arguments to client, don't preparse $@ into a variable
  1131. and then pass that variable along to the client via rsh.
  1132.  
  1133. Instead, of setting and resetting the cmd line args for IFS hacking, push 
  1134. a marker on the arg list and push other things on the front.  Then 
  1135. shift things off the front and stop when you get to the marker.
  1136.  
  1137. at the end, just pass $@ along as the arguments to the client.
  1138.  
  1139. set new stuff XYZZY "$@"
  1140.  
  1141. @EOF
  1142. set `wc -lwc <FUTURE-WORK`
  1143. if test $1$2$3 != 856243606
  1144. then
  1145.     echo ERROR: wc results of FUTURE-WORK are $* should be 85 624 3606
  1146. fi
  1147.  
  1148. chmod 444 FUTURE-WORK
  1149.  
  1150. if test -f Imakefile
  1151. then
  1152.     echo Ok to overwrite existing file Imakefile\?
  1153.     read answer
  1154.     case "$answer" in
  1155.     [yY]*)    echo Proceeding;;
  1156.     *)    echo Aborting; exit 1;;
  1157.     esac
  1158.     rm -f Imakefile
  1159.     if test -f Imakefile
  1160.     then
  1161.         echo Error: could not remove Imakefile, aborting
  1162.         exit 1
  1163.     fi
  1164. fi
  1165. echo x - Imakefile
  1166. cat >Imakefile <<'@EOF'
  1167. XCOMM Copyright 1991 by James J. Dempsey <jjd@bbn.com>
  1168. XCOMM 
  1169. XCOMM Permission to use, copy, modify, distribute, and sell this software and 
  1170. XCOMM its documentation for any purpose is hereby granted without fee, 
  1171. XCOMM provided that the above copyright notice appear in all copies and that 
  1172. XCOMM both that copyright notice and this permission notice appear in 
  1173. XCOMM supporting documentation, James J. Dempsey makes no representations 
  1174. XCOMM about the suitability of this software for any purpose.  It is provided 
  1175. XCOMM "as is" without express or implied warranty.
  1176.  
  1177. PROGRAMS = xrsh xrlogin
  1178.  
  1179. all:: $(PROGRAMS)
  1180.  
  1181. InstallNamedProg(xrsh.sh,xrsh,$(BINDIR))
  1182. InstallManPage(xrsh,$(MANDIR))
  1183. InstallNamedProg(xrlogin.sh,xrlogin,$(BINDIR))
  1184. InstallManPage(xrlogin,$(MANDIR))
  1185.  
  1186. depend::
  1187. @EOF
  1188. set `wc -lwc <Imakefile`
  1189. if test $1$2$3 != 2097775
  1190. then
  1191.     echo ERROR: wc results of Imakefile are $* should be 20 97 775
  1192. fi
  1193.  
  1194. chmod 444 Imakefile
  1195.  
  1196. if test -f README
  1197. then
  1198.     echo Ok to overwrite existing file README\?
  1199.     read answer
  1200.     case "$answer" in
  1201.     [yY]*)    echo Proceeding;;
  1202.     *)    echo Aborting; exit 1;;
  1203.     esac
  1204.     rm -f README
  1205.     if test -f README
  1206.     then
  1207.         echo Error: could not remove README, aborting
  1208.         exit 1
  1209.     fi
  1210. fi
  1211. echo x - README
  1212. cat >README <<'@EOF'
  1213. This distribution contains two programs, xrsh and xrlogin. 
  1214.  
  1215. Both are shell scripts.
  1216.  
  1217. Xrsh is designed to allow you to start an X client on a remote machine
  1218. with the window displayed on the current server's $DISPLAY.  It has
  1219. many options that give you the ability to propagate environment
  1220. variables (including DISPLAY) to the remote system and works with
  1221. various types of X server access control including xauth and xhost.
  1222.  
  1223. In X11R4 and previous, xrsh was called "xon".  There was a script in
  1224. X11R5 by Keith Packard by that name which has no relation to the
  1225. originally distributed xon script.
  1226.  
  1227. Xrlogin opens a local xterm window and runs rlogin or telnet to
  1228. connect to a remote machine.
  1229.  
  1230. Starting with the X11R5 version, xrsh has many new features
  1231. including a multitude of X access control methods, the ability to pass
  1232. arbitrary environment variables to the remote host and the ability to
  1233. start a client on a different screen than the current one.
  1234.  
  1235. To install on your system, the usual thing is to do an "xmkmf"
  1236. followed by a "make install".
  1237.  
  1238. IMPORTANT:
  1239.  
  1240. If you are running a System V variant, you may need to change the
  1241. first line of both scripts from "#!/bin/sh" to ": ".
  1242.  
  1243. James J. Dempsey
  1244. jjd@bbn.com
  1245. 4 October 1991
  1246. Updated for X11R6: 3 June 1994
  1247. @EOF
  1248. set `wc -lwc <README`
  1249. if test $1$2$3 != 342161250
  1250. then
  1251.     echo ERROR: wc results of README are $* should be 34 216 1250
  1252. fi
  1253.  
  1254. chmod 444 README
  1255.  
  1256. exit 0
  1257.